/***************************************************************************
 *   Copyleft 2006-2007 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>									   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __GREGORY_SURFACE_H__
#define __GREGORY_SURFACE_H__

#include "./BezierSurface.h"

class GregorySurface: public BezierSurface {
private:
	DynamicArray2D<Point4D> mPolygons;

	Point4D CalculatePoint(cFloat u, cFloat v);
	cVoid CalculateHermite(cFloat t, cFloat *out);

protected:
	virtual cVoid CalculateBasis();
	virtual cVoid CalculateSurface();
	
public:

    /**************************************************************
    * Constructors                                                *
    ***************************************************************/
    GregorySurface();
    ~GregorySurface(); 
        
    /**************************************************************
    * Operators                                                   *
    ***************************************************************/


    /**************************************************************
    * Other helpful functions                                     *
    ***************************************************************/
	Point4D Q[2][2], Qv[2][2], Qu[2][2], Quv[2][2], Qvu[2][2];
	Point4D P[2][2], Pv[2][2], Pu[2][2], Puv[2][2], Pvu[2][2];

	cVoid BezierToHermite();

	virtual cChar* GetName();
	virtual cVoid DisplayInfo(Renderer& renderer);
	virtual cVoid Render(Renderer& renderer, Matrix4D& matrix, ProjectionPlane& plane);
	virtual cVoid Render(Renderer& renderer, Matrix4D& matrix, ProjectionPlane& plane, cWinColor color);
};                                                                 

#endif // __GREGORY_SURFACE_H__